<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>本地取歌</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!--标准 mui.css-->
    <!--App 自定义的 css-->
    <style>
        ul, ol {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        #box {
            width: 300px;
            /*margin: 50px auto;*/
            /*position: relative;*/
            padding: 40px 0 10px 10px;
            position: fixed;
            background-color:white;
            z-index: 111;
        }

        #txtSearch {
            width:200px;
            height:1.2em;
            line-height:24px;
            padding:5px 8px;
            float: right;
            margin-top: -5px;
            /*border-right: 0;*/
        }
        #b{
            width:80px;
            padding:1px 8px;
            float: right;
        }
        .input{
            border: 1px solid #b6b6b6;
            width: 90px;
        }
        .input:empty::before {
            content: attr(placeholder);
        }
        button {
            float: left;
            width: 150px;
            height: 34px;
            font: 400 14px/34px "microsoft yahei";
            color: white;
            background: #3385ff;
            cursor: pointer;
            border:1px solid white;
        }

        button:hover {
            background: #317ef3;
        }
        #popp{
            float:right;
            width: 210px;
            border: 1px solid #ccc;
            padding: 2px;
            position: absolute;
            top: 63px;
            right:0;
            height: 280px;
        }
        #pop{overflow: auto;
            width: 210px;
            height: 280px;

            /*overflow:auto;*/
        }
        #pop ul li {
            padding-bottom: 5px;
            padding-left: 5px;
        }

        #pop ul li:hover {
            background-color: #317ef3;
            color: #ffffff;
        }
        .rightBut{
            /*font-family: Verdana, Arial, Helvetica, sans-serif;*/
            /*font-size: 0.9em;*/
            /*color: #333;*/
            /*text-align: left;*/
            /*white-space: nowrap;*/
            position: absolute;
            top: 35px;
            right: 0;
        }
        .combo-arrow{
            /*font-family: Verdana, Arial, Helvetica, sans-serif;*/
            /*font-size: 0.9em;*/
            text-align: center;
            padding-top: 5px;
            /*white-space: nowrap;*/
            /*text-decoration: none;*/
            outline-style: none;
            /*overflow: hidden;*/
            display: inline-block;
            /*vertical-align: top;*/
            /*cursor: pointer;*/
            /*opacity: 0.6;*/
            background: url('http://yinyingyang.gitee.io/img/combo_arrow.png') no-repeat center center;
            width: 28px;
            height: 32px;
        }
        .footer{
            width: 150px;
            margin: 0 auto;
            position: fixed;
            bottom: 0;
            padding: 30px 30px 10px 30px;
            z-index: 1111;
            /*left: 0;*/
            right: 0;
            background-color:white;
        }
        form{
            width: 100%;
            font-size: 1em;
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
        }
        #c{
            position: absolute;
        }
        label{margin-left: 34px;}
    </style>
    <script src="http://yinyingyang.gitee.io/js/pinyin.js"></script>
</head>

<body id="c">
<div style="position: fixed;
            top: 20px;
            z-index: 1111;
            margin: auto;
            right: 20px;"><input id="no" type="button" value="转屏"/></div>
<form id="form" name="showUI_commit" method="post" action="/set_event">

    <div id="box">
        <span class="rightBut">
            <span onclick="javascript:popp?(openClose(popp),showAll()):showMusic()"
                  class="combo-arrow"
                  icon-index="0" tabindex="-1"></span>
        </span>
        <label>选歌：<div id="txtSearch"class="input" contenteditable="true">随机播放</div></label>
        <!--<input type="button" value="搜索" id="btnSearch">-->
    </div>
    <br>
    <br>
    <div class="footer">
        <p><input type="checkbox" name="item" ><label>无悬浮键</label></p>
        <p><input type="checkbox" name="item"><label>多弹</label></p>
        <p><input type="checkbox" name="item"><label>按键初始化</label></p>
        <p><input type="checkbox" name="item" onchange="changeRotate()" ><label>HOME在左</label></p>
        <p>速度：<select id="select"></select></p>
        <button id="actions" type="button">弹奏</button>
        <button id="cancel" type="button">取消</button>

    </div>

</form>
<script type="text/javascript">
    var box = document.getElementById("box");
    var txt = document.getElementById("txtSearch");
    var names = `]]..music2str()..[[`.split(',');//pinyin.getCamelChars(chinaName)拼音后续加
    var popp=null//歌曲列表
    var music=1//选的歌
    var isrotate=1
    let loadRotate=1;
    let bs=`]]..speed2str()..[[`.split(',')
    let bStr=""
    for(var i=0;i<bs.length;i++){
        bStr+=`<option value=${i}>${bs[i]}</option>`
    }
    document.getElementById("select").innerHTML=bStr

    function actions(data) {//数据提交 post 请求
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "/set_event", true);
        xhr.setRequestHeader("Content-type", "application/json");
        xhr.onreadystatechange = function () {
            var XMLHttpReq = xhr;
            if (XMLHttpReq.readyState == 4) {
                if (XMLHttpReq.status == 200) {
                    var text = XMLHttpReq.responseText;
                    console.log(text);
                } else {
                    console.log(XMLHttpReq.status)
                }
            } else {
                console.log(XMLHttpReq.readyState);
            }
        };
        //alert('{"name": "showUI_commit","value":' + data + '}')
        xhr.send('{"name": "showUI_commit","value":"' + data + '"}');
    }

    function closed() {//取消 post请求
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "/set_event", true);
        xhr.setRequestHeader("Content-type", "application/json");
        xhr.onreadystatechange = function () {
            var XMLHttpReq = xhr;
            if (XMLHttpReq.readyState == 4) {
                if (XMLHttpReq.status == 200) {
                    var text = XMLHttpReq.responseText;
                    console.log(text);
                } else {
                    console.log(XMLHttpReq.status)
                }
            } else {
                console.log(XMLHttpReq.readyState);
            }
        };
        xhr.send('{"name": "showUI_cancel"}');
    }
    document.getElementsByTagName('input').onchange = function (e) {
        console.log(e)
    }
    document.getElementById('actions').onclick = function () {//数据提交按钮点击
        let c=checked()
        let b=document.getElementById("select").value
        actions(music+','+c+','+b);
    }
    document.getElementById('cancel').onclick = function () {//取消按钮点击
        closed();
    }
    document.getElementById('no').onclick = function () {//取消按钮点击
        isrotate?noRotate():rotate()
    }
    const contentDOM = document.getElementById('c');
    const width = document.documentElement.clientWidth;
    const height = document.documentElement.clientHeight;
        function rotate() {
            if (window.orientation == 180 || window.orientation == 0) {
                contentDOM.style.width = height + 'px';
                contentDOM.style.height = width + 'px';
                contentDOM.style.top = (height - width) / 2 + 'px';
                contentDOM.style.left = 0 - (height - width) / 2 + 'px';
                contentDOM.style.transform = loadRotate==2?'rotate(270deg)':'rotate(90deg)';
                isrotate=1
            }
        }
        rotate()
        function noRotate() {
            contentDOM.style.width = width + 'px';
            contentDOM.style.height = height + 'px';
            contentDOM.style.top = '0px';
            contentDOM.style.left = '0px';
            contentDOM.style.transform = 'none';
            isrotate=0
        }
        function changeRotate() {
            loadRotate=loadRotate==2?1:2
            isrotate&& rotate()
        }
    //    window.addEventListener("load", rotate, false);
    //    window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", rotate, false);
</script>
<script src="js/localMusic.js"></script>
</body>
</html>